home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / sampler4.arc / IO.SAC < prev    next >
Text File  |  1985-08-30  |  29KB  |  841 lines

  1. ON ECHO
  2. !*******************************************************************!
  3. !                                                                   !
  4. !                Data Input and Output in SORITEC Sampler           !
  5. !                        (Chapters 3 and 4)                         !
  6. !                                                                   !
  7. !*******************************************************************!
  8. !    
  9. !    SORITEC Sampler can import and export data in a number of formats.
  10. !    In addition, Sampler supports a complete databanking facility that
  11. !    allows you to maintain all of SORITEC's data types, plus GROUPS and
  12. !    equations with a simple set of commands.  This demonstration
  13. !    illustrates most of these capabilities.
  14. !    
  15. !*******************************************************************!
  16. !                                                                   !
  17. !                         Keyboard  Entry                           !
  18. !                          (Section 3.4)                            !
  19. !                                                                   !
  20. !*******************************************************************!
  21. !    
  22. !    Data are entered directly from the terminal keyboard with the
  23. !    FILL command, e.g.,
  24. !    
  25.  
  26. FILL short_series_a 4 6 8 3 6 8 3 5 8 2
  27.  
  28. !    
  29. !    If no USE command is in effect, SORITEC Sampler counts the number of
  30. !    observations associated with the variable and sets the USE period 
  31. !    accordingly.  Let's  enter the USE command with no arguments to
  32. !    see how Sampler defined the USE period for the previous FILL command.
  33. !    
  34.  
  35. USE
  36.  
  37. !    
  38. !    You can use a standard FORTRAN repeat operator to enter consecutive 
  39. !    numbers with the same value, e.g.,
  40. !    
  41.  
  42. FILL short_series_b 5 3*6 4 9.3 2*10.1 8 14
  43.  
  44. !    
  45. !    If you enter more observations for a variable than defined by
  46. !    the current USE period, SORITEC Sampler returns an error and
  47. !    ignores the command, e.g.,
  48. !    
  49.  
  50. FILL too_long 3 6 8 4 6 7 3 6 9 5 3 8
  51.  
  52. !    
  53. !    You must change the USE period to accommodate the number of 
  54. !    observations when there are more data to be entered than allowed
  55. !    by the current USE period.  Any periodicity of time series, 
  56. !    included undated data types, may be entered from the terminal. 
  57. !    
  58.  
  59. USE 1980m1 1980m12
  60. FILL too_long 3 6 8 4 6 7 3 6 9 5 3 8
  61.  
  62. !    
  63. !    Normally, Sampler generates an error and ignores the command when
  64. !    too few data items are entered.
  65. !    
  66.  
  67. FILL too_short 4 5 7 3 4
  68.  
  69. !    
  70. !    However, if you enable the RAGGED option with the ON RAGGED command,
  71. !    data series shorter than the current USE period are accepted.  The
  72. !    remaining observations are assigned MISSING values.
  73. !    
  74.  
  75. ON RAGGED
  76. FILL too_short 4 5 7 3 4
  77. OFF RAGGED
  78. PRINT too_long too_short
  79.  
  80. !    
  81. !    The FILL command is commonly used to enter short data series or to
  82. !    extend or revise existing data series.  For example, extending the
  83. !    variable "too_short" be three observations is easy.
  84. !    
  85.  
  86. USE 1980m6 1980m8
  87. FILL new_data 4 5 8
  88. REVISE too_short = new_data
  89. USE 1980m1 1980m12
  90. PRINT too_long too_short
  91.  
  92. !    
  93. !    More information about data revision in SORITEC Sampler is given
  94. !    in the file, "revise.sac".
  95. !    
  96. !*******************************************************************!
  97. !                                                                   !
  98. !                     SAL File Input and Output                     !
  99. !                          (Section 3.1)                            !
  100. !                                                                   !
  101. !*******************************************************************!
  102. !    
  103. !    SORITEC SAL files are the most convenient way to transfer data into
  104. !    Sampler.  SAL files are simply unformatted flat-ASCII files that
  105. !    have special headers and trailers that identify the USE period
  106. !    and variable names.  A sample SAL file is shown below.
  107. !    
  108. !     USE    1978      1983       
  109. !     READ    total_population
  110. !        222585.0000    225055.0000    227738.0000    230019.0000     
  111. !        232309.0000    234496.0000           
  112. !       ;
  113. !     READ    male_population
  114. !        108424.0000    109584.0000    110874.0000    111984.0000     
  115. !        113105.0000    114179.0000
  116. !       ;
  117. !     END
  118. !     READ    female_population
  119. !        114161.0000    115472.0000    116864.0000    118034.0000     
  120. !        119204.0000    120317.0000               
  121. !       ;
  122. !     END
  123. !    
  124. !    To read a SAL file, simply enter READ(filename).  The header 
  125. !    informs Sampler what the USE period of the data is and what
  126. !    the variable names are.  The file above is stored under the name 
  127. !    "popdata.sal" on this demonstration diskette, which is assumed 
  128. !    to be in the a: drive.  To read it, simply enter:
  129. !    
  130.  
  131. READ('a:popdata')
  132.  
  133. !    
  134. !    There are several things to note about this command:
  135. !      (1) The .SAL extension is omitted from the filename argument.
  136. !          Any file that is read with the READ command must have a
  137. !          .SAL extension.  Including the file extension will generate 
  138. !          an error.
  139. !      (2) If the file is in other than the current directory, the
  140. !          filename must be enclosed within single quotes.
  141. !      (3) In executing the READ statement, SORITEC Sampler reads
  142. !          data until it encounters an END statement.  A subsequent
  143. !          READ of the same file continues reading the file until
  144. !          another END statement is found.
  145. !    
  146. !    In the example above, SORITEC Sampler has read "total_population"
  147. !    and "male_population" into the workspace.  You can find this out
  148. !    by entering the command SYMBOLS, e.g.,
  149. !    
  150.  
  151. SYMBOLS
  152.  
  153. !    
  154. !    Let's READ in "female_population" now with another READ command.
  155. !    
  156.  
  157. READ('a:popdata')
  158. SYMBOLS
  159.  
  160. !    
  161. !    A SAL file can contain as many blocks, delimited by END statements
  162. !    as disk space permits.  Also, SAL files can contain variables of
  163. !    mixed periodicities.  Simply insert a USE statement before the READ
  164. !    statement that identifies the variable.
  165. !    
  166. !    Data may be written to files in SAL file format with the PUNCH command.
  167. !    This is particularly useful if you wish to export data to another 
  168. !    SORITEC on another type of computer since data transfer
  169. !    is essentially transparent and yet the data are in ASCII format.
  170. !    
  171. !    PUNCH only writes to a file named PUNCH1.SAL in the current directory.
  172. !    Unlike file naming in the READ command, you cannot direct output to any
  173. !    other file name.  Use the DOS REN command to change the file name after
  174. !    terminating SORITEC Sampler.  Note that if a file PUNCH1.SAL already
  175. !    exists on your directory, SORITEC Sampler will delete it and open a new
  176. !    file PUNCH1.SAL.  The PUNCH command will be superceded by more general 
  177. !    output commands in later versions of SORITEC.
  178. !    
  179. !    Let's say we want to write a SAL file containing (1) the difference
  180. !    between female and male populations, and (2) the ratio of female to
  181. !    total population.  First, make the appropriate calculations.
  182. !    
  183.  
  184. pop_difference = female_population - male_population
  185. female_proportion = female_population/total_population
  186.  
  187. !    
  188. !    Now write out a SAL file called to the current directory.  If you
  189. !    are running Sampler off a hard disk system, the file will be written
  190. !    to the directory which contains the Sampler program.  If you are
  191. !    running the program on a floppy disk system, the file will be written
  192. !    on the a: drive.  We'll only demonstrate the PUNCH command with a 
  193. !    small amount of data since space is limited if you are running Sampler 
  194. !    on a double-floppy system.
  195. !    
  196.  
  197. PUNCH pop_difference female_proportion
  198.  
  199. !    
  200. !    Note that SORITEC Sampler leaves the SAL file open for 
  201. !    additional data output until you PUNCH to another file or the
  202. !    SORITEC Sampler is terminated.  When the file is closed, an END
  203. !    statement is appended to it.  No intervening END statements are
  204. !    inserted into the file, for example, after each PUNCH statement
  205. !    is executed.  Remember, if PUNCH1.SAL already exists on the current 
  206. !    directory, it is deleted before the data associated with the PUNCH 
  207. !    command are written.  Unlike SORITEC Databanks, SAL files can only 
  208. !    be "managed" by DOS commands.
  209. !    
  210. !*******************************************************************!
  211. !                                                                   !
  212. !                     DIF File Input and Output                     !
  213. !                          (Section 3.2)                            !
  214. !                                                                   !
  215. !*******************************************************************!
  216. !    
  217. !    Data can be transferred between most population PC packages that
  218. !    support the DIF file format.  
  219. !    
  220. !    For DIF file input, use the READDIF command.  Although the command syntax
  221. !    is similar to the READ command, there are some important differences.
  222. !         (1) READDIF does not interpret dates in the DIF file so you 
  223. !             must specify the USE period for the data before you enter
  224. !             the READDIF command.
  225. !         (2) If variable names are not in the DIF file, they must be
  226. !             entered in the command line.
  227. !    
  228. !    As an example, consider the DIF file generated by LOTUS' Translate
  229. !    utility.  If you have a copy of LOTUS, this worksheet from which the
  230. !    data were translated is in "POPNEW.WKS".  The worksheet consists of
  231. !    two labelled columns containing the variables "popciv" and "poh" for
  232. !    the period 1982m1 to 1983m12.  The worksheet has been translated to a
  233. !    file named "popnew.dif".
  234. !    
  235. !    To import the data, set the USE period:
  236. !    
  237.  
  238.  
  239. USE 1982m1 1983m12
  240.  
  241. !    
  242. !    then read the DIF file with the command:
  243. !    
  244.  
  245. READDIF('a:popnew')
  246.  
  247. !    
  248. !    If the DIF file was not labelled, the command line would be:
  249. !    
  250. !               READDIF('a:popnew') popciv poh
  251. !    
  252. !    
  253. !    Data are exported in DIF file format using the PUNCHDIF command.
  254. !    For example, if you wanted to export the 1982 values of "poh" and
  255. !    "popciv" to the file "popdata.dif", the command would be:
  256. !    
  257.  
  258. USE 1982m1 1982m12
  259. PUNCHDIF('a:popdata') poh popciv
  260.  
  261. !    
  262. !    If you have a copy of LOTUS, use the Translate utility to convert
  263. !    the file into a worksheet.  Note that LOTUS translates the dates into
  264. !    a variable called "time" and writes these data to the first column 
  265. !    (or row) of the worksheet.  When dates are in the DIF file,  SORITEC
  266. !    Sampler assigns MISSING values to "time".  DIF files are managed by
  267. !    DOS, so use DOS commands to delete, copy, rename, etc. the files.
  268. !    
  269. !*******************************************************************!
  270. !                                                                   !
  271. !                     Formatted Input and Output                    !
  272. !                           (Section 3.2)                           !
  273. !                                                                   !
  274. !*******************************************************************!
  275. !    
  276. !    Formatted input and output is similar to that in FORTRAN programs.
  277. !    The format of the data that are to be imported or exported are
  278. !    specified in a FORMAT statement, identified by a statement number.
  279. !    Data are read or written in the desired format by refering to the
  280. !    statement number that defines that format.  Data may be read or
  281. !    written in formatted form either to files or the terminal with the
  282. !    READ and WRITE commands.
  283. !    
  284. !    Note that you may WRITE data to an output device without refering
  285. !    to a FORMAT statment number.  In this case, data are written as
  286. !    they are with the PRINT command, e.g., writing "male_population"
  287. !    and "female_population" to the terminal results in the following
  288. !    output:
  289. !    
  290.  
  291. USE 1978 1983
  292. WRITE male_population female_population
  293.  
  294. !    
  295. !    Formatted input and output is demonstrated in an example whereby
  296. !    we wish to read from a file data in tabular form.  The data are
  297. !    defined as in the following table.
  298. !    
  299. !  1st row -->            KEY MACROECONOMIC INDICATORS
  300. !                             
  301. !    Year   Gross Nat. Product    Civ. Labor Force    Corporate Profits 
  302. !            (billions of $)    (millions of persons)  (billions of $)     
  303. !    1980        2631.7               106.940               149.829
  304. !    1981        2957.8               108.670               140.009
  305. !    1983        3069.3               110.205               104.843
  306. !    1984        3304.8               111.551               127.414
  307. !
  308. !    ^
  309. !    |
  310. ! 1st column
  311. !     
  312. !    You should always leave a blank line at the end of the file to avoid
  313. !    spurious READ errors. 
  314. !
  315. !    To read the data, first set up the format statement.  Use of integer 
  316. !    (I) format is not advised for input so the year data should be read
  317. !    in as REAL.
  318. !    
  319.  
  320. 100 FORMAT(///4(/f4.0,8x,f6.1,15x,f6.0,15x,f6.0))
  321.  
  322. !    
  323. !    Next, define the USE period for the data.
  324. !
  325.  
  326. USE 1980 1983
  327.  
  328. !
  329. !    When importing data with a formatted READ, SORITEC Sampler normally 
  330. !    expects to read in one observation at a time, re-using the format
  331. !    from the start for each observation.  If you are putting more than
  332. !    one observation on each input record, or you need to skip some initial
  333. !    input records, you need to enable the STREAMIO global option using
  334. !    the ON STREAMIO command.  This causes SORITEC to compute the total
  335. !    number of data points to be read (i.e., the number of observations
  336. !    multiplied by the number of variables), and then read the entire
  337. !    mass of data in a single formatted READ, reusing the format only as
  338. !    and when necessary.
  339. !    
  340.  
  341. ON STREAMIO
  342.  
  343. !
  344. !    Now import the data with the READ command.  We'll read the data
  345. !    directly from this command file to save space on the demonstration
  346. !    diskette.
  347. !    
  348.  
  349. READ(100) year gnp clf profits
  350.                      KEY MACROECONOMIC INDICATORS
  351.                          
  352. Year   Gross Nat. Product    Civ. Labor Force    Corporate Profits 
  353.         (billions of $)    (millions of persons)  (billions of $)     
  354. 1980        2631.7               106940               149829
  355. 1981        2957.8               108670               140009
  356. 1983        3069.3               110205               104843
  357. 1984        3304.8               111551               127414
  358.  
  359.  
  360. !
  361. !    Print out the values of the variables for verification.
  362. !    
  363.  
  364. PRINT year gnp clf profits
  365.  
  366. !    
  367. !    Let's add population to the table and print it out row-wise rather then 
  368. !    column-wise.  We'll write the table to the terminal instead of disk to 
  369. !    save some room.
  370. !    
  371. !    Set up the format statement.
  372. !    
  373.  
  374. 200 FORMAT(//10x,'Key Macroeconomic Indicators Including Population'/)
  375. 201 FORMAT(19x,4(8x,f5.0)/18x,4(9x,4('-')))
  376. 202 FORMAT(1x,'Gross Nat. Product',4(3x,f10.1)/' (billions of $)'/)
  377. 203 FORMAT(1x,'Civ. Labor Force  ',4(5x,f8.0)/' (thousands of persons)'/)
  378. 204 FORMAT(1x,'Corporate Profits ',4(5x,f8.0)/' (millions of $)'/)
  379. 205 FORMAT(1x,'Total Population  ',4(5x,f8.0)/' (thousands of persons)'/)
  380.  
  381. !    
  382. !    Use the WRITE command to write out the table.  Note that to prevent 
  383. !    the echoing of the WRITE commands in between the output, disable the 
  384. !    ECHO option with the OFF ECHO command.
  385. !    
  386.  
  387. OFF ECHO
  388. WRITE(200)
  389. WRITE(201) year
  390. WRITE(202) gnp
  391. WRITE(203) clf
  392. WRITE(204) profits
  393. WRITE(205) total_population
  394. ON ECHO
  395.  
  396. !    
  397. !    If this table had been written to disk, it would have been
  398. !    written with the command:
  399. !    
  400. !         WRITE(filename 200)
  401. !         WRITE(filename 201) year
  402. !         WRITE(filename 202) gnp
  403. !         WRITE(filename 203) clf
  404. !         WRITE(filename 204) profits
  405. !         WRITE(filename 205) total_population
  406. !    
  407. !    The table would reside in the file "filename.lst".
  408. !    
  409. !    Formatted data can be written to the terminal or file in column-wise
  410. !    organization.  To do this, enclose the variable list in parentheses.
  411. !    For example, if you wanted to write "year", "gnp", "clf" and "profits" 
  412. !    in the same format as the table that was input, the command would be:
  413. !    
  414. !         WRITE(filename 100) (year gnp clf profits)
  415. !
  416. !
  417. !
  418. !*******************************************************************!
  419. !                                                                   !
  420. !                SORITEC Sampler Databanking Commands               !
  421. !                          (Chapter 4)                              !
  422. !                                                                   !
  423. !*******************************************************************!
  424. !    
  425. !    SORITEC databanks are the key to using Sampler efficiently.  Databanks
  426. !    can store data series, equations, matrices, vectors, parameters,
  427. !    GROUPS and even entire models in the full version of SORITEC.
  428. !    SORITEC databanks are created, managed and deleted entirely within
  429. !    SORITEC Sampler.  In your DOS directory, they are identified by
  430. !    the extension, "SDB".  This section of the demonstration illustrates
  431. !    the capabilities of the SORITEC Sampler's databanking facility.
  432. !    
  433. !    Data banks are created with the CREATE command (but first we'll
  434. !    attempt to PURGE it in case it already exists), e.g.,
  435. !    
  436.  
  437. PURGE 'a:ecdata'
  438.  
  439. !
  440. !    Don't worry about the message if the file was not found.
  441. !
  442.  
  443. CREATE 'a:ecdata'
  444.  
  445. !    
  446. !    Note that when redirecting output to another drive or directory,
  447. !    the filename must be enclosed within single quotes.  Otherwise,
  448. !    simply enter the filename.  In out example, we should now have a 
  449. !    databank file named "ecdata.sdb" on the a: drive.  Note that
  450. !    the "SDB" extension is not included with the file name in the 
  451. !    command line.  Databank names must be 8 characters or less to conform
  452. !    to DOS naming conventions.
  453. !    
  454. !    You save data in a databank with the KEEP command.  For example,
  455. !    to save "gnp", "clf", and "profits" data that we used earlier,
  456. !    enter:
  457. !    
  458.  
  459. KEEP gnp clf profits
  460.  
  461. !    
  462. !    To verify the contents of the databank you have currently attached,
  463. !    enter the CONTENTS command, e.g.,
  464. !    
  465.  
  466. CONTENTS
  467.  
  468. !    
  469. !    KEEP saves all observations associated your data series regardless
  470. !    of the currently active USE period.  If you want to save only the 
  471. !    active observations, you must enter the keyword ACTIVE as a
  472. !    modifier to the command.  For example, suppose we want to save
  473. !    only the 1982 and 1983 values of "pop_difference" and 
  474. !    "female_proportion" in "ecdata".  Then change the USE period to
  475. !    the 1982 to 1983 period, and then KEEP them with the ACTIVE 
  476. !    modifier included in the command line.
  477. !    
  478.  
  479. USE 1982 1983
  480. KEEP(ACTIVE) pop_difference female_proportion
  481.  
  482. !    
  483. !    Only the observations for 1982 and 1983 will be saved.
  484. !    
  485. !    Note that once we have these variables in the databank, we can
  486. !    remove them from SORITEC Sampler's symbol table with the FORGET
  487. !    command, e.g.,
  488. !    
  489.  
  490. FORGET pop_difference female_proportion
  491.  
  492. !    
  493. !    If you type SYMBOLS, you will note that these two variables are not
  494. !    longer in Sampler's workspace.  While we have them in the "ecdata"
  495. !    databank, we only have the observations for 1982 and 1983.  Previous
  496. !    observations are lost, once cleared from the workspace.
  497. !    
  498. !    You can explicitly detach a SORITEC databank from your job session
  499. !    with the RETURN command.  For example,
  500. !    
  501.  
  502. RETURN
  503.  
  504. !    
  505. !    closes "ecdata.sdb" and detaches it from SORITEC Sampler.  Databanks
  506. !    are automatically returned when you CREATE a new databank or access
  507. !    an existing one.  
  508. !    
  509. !    If you want to attach an existing databank, you ACCESS it, e.g.,
  510. !    
  511.  
  512. ACCESS 'a:ecdata'
  513.  
  514. !    
  515. !    You can implicitly access a databank with the CONTENTS command.  For
  516. !    example, "CONTENTS ecdata" would return any attached databank, access
  517. !    the named databank and produce a listing of variables it contains.
  518. !    
  519. !    Let's demonstrate some the the things that can be stored in SORITEC
  520. !    Sampler's databanks.  To do this, we'll create a databank on the "a:"
  521. !    drive to store population-related information.  Again, we'll attemp
  522. !    to PURGE it in case it already exists.
  523. !    
  524.  
  525. PURGE 'a:popdata'
  526.  
  527. !
  528. !    If the file does not already exist, you will receive a message.
  529. !
  530.  
  531. CREATE 'a:popdata'
  532.  
  533. !    
  534. !    Let's define a GROUP to reference the three annual population variables
  535. !    that we started out with in this demonstration, "total_population",
  536. !    "male_population" and "female_population".
  537. !    
  538.  
  539. GROUP pop_group total_population male_population female_population
  540.  
  541. !    
  542. !    Print out the data after restoring the original USE period.
  543. !    
  544.  
  545. USE 1978 1983
  546. ON GROUP
  547. PRINT pop_group
  548.  
  549. !    
  550. !    We can use the GROUP definition to store all population data in a
  551. !    single command with one argument, e.g.,
  552. !    
  553.  
  554. KEEP pop_group
  555.  
  556. !    
  557. !    Now if you think you might want to refer to these three population
  558. !    variables as a group later,  store the GROUP definition, as well,
  559. !    by first turning OFF the group expansion option and then KEEPing
  560. !    the GROUP.
  561. !    
  562.  
  563. OFF GROUP
  564. KEEP pop_group
  565.  
  566. !    
  567. !    The next time you want to go into this databank, simply retrieve the 
  568. !    GROUP with the group expansion option turned off, enable group expansion
  569. !    with the ON GROUP command and then copy the data from the databank by
  570. !    refering to the GROUP definition.
  571. !    
  572. !    SORITEC Sampler can also store equations.  Since we lost some
  573. !    observations for "pop_difference" and "female_proportion" because
  574. !    we chose only to store the ACTIVE observations, let's define
  575. !    equations for the two variables and store the equations in
  576. !    the "popdata.sdb" databank so that we can recreate the data from
  577. !    the other variables in the databank.
  578. !    
  579. !    First, define the equations:
  580. !    
  581.  
  582. equation  pop_dif  pop_difference = female_population - male_population
  583. equation  fem_prop female_proportion = female_population/total_population
  584.  
  585. !    
  586. !    and then KEEP them.
  587. !    
  588.  
  589. KEEP pop_dif fem_prop
  590.  
  591. !    
  592. !    You can similarly store vectors, parameters, constants and matrices
  593. !    generated by Sampler.  Remember that since Sampler does not support
  594. !    matrix operations generally, the only matrices you'll be able to
  595. !    store are those generated by the various estimation commands and
  596. !    the XTAB command.
  597. !    
  598. !    Let's forget everything from Sampler's workspace since all the
  599. !    important information is now in the two databanks.
  600. !    
  601.  
  602. FORGET *
  603.  
  604. !    
  605. !    Several other utilities are available to manage items in your
  606. !    databanks.  To show these let's ACCESS "ecdata.sdb" from the a:drive.
  607. !    
  608.  
  609. ACCESS 'a:ecdata'
  610. CONTENTS
  611.  
  612. !    
  613. !    Suppose we want to rename items in a databank.  This is done with the
  614. !    RENAME command.  For example, to rename "gnp" to "gnp_in_current_dos"
  615. !    the command would be:
  616. !     
  617.  
  618. USE 1980 1983
  619.  
  620. RENAME gnp_in_current_dollars gnp
  621.  
  622. !    
  623. !    Note the argument order in this command: RENAME new_name old_name
  624. !    
  625. !    For practice, we'll rename the other two economic items, clf and
  626. !    profits so that their units are identified with the variable name.
  627. !    
  628.  
  629. RENAME profits_mil_of_dols clf
  630. RENAME clf_thous_pers profits
  631.  
  632. !    
  633. !    Whoops!  We assigned the wrong names to the two variables.  Oh well,
  634. !    this is a good time to demonstrate the SWITCH command, which allows
  635. !    you to switch the names of two variables.
  636. !    
  637.  
  638. SWITCH profits_mil_of_dols  clf_thous_pers
  639.  
  640. !    
  641. !    Now the correct names will be associated with the proper data.
  642. !    One important thing to remember about renaming or switching the
  643. !    names of items in databanks.  If you change the name of an item
  644. !    and that item is also defined in a GROUP, the group definition
  645. !    is NOT automatically updated and you will be unable to reference
  646. !    the data from the original group definition.
  647. !    
  648. !    
  649. !    Retrieving items from a databank is even easier than saving them.
  650. !    You can either COPY them explicitly or simply reference them in
  651. !    a legal SORITEC Sampler command.  If Sampler cannot find the item
  652. !    in its workspace it automatically searches any attached databank
  653. !    to see if it exists there.  If it does, the item is copied to the
  654. !    workspace and used as required.
  655. !    
  656. !    The copy command is simply:
  657. !    
  658.  
  659. COPY profits_mil_of_dols clf_thous_pers
  660.  
  661. !    
  662. !    Let's make sure the item names are associated with the right data.
  663. !    
  664.  
  665. PRINT profits_mil_of_dols clf_thous_pers
  666.  
  667. !    
  668. !    Note that these items are now back in Sampler's workspace.
  669. !    
  670.  
  671. SYMBOLS
  672.  
  673. !    
  674. !    We could have just as easily printed the data without explicitly
  675. !    copying it as shown for gnp_in_current_dollars
  676. !    
  677.  
  678. PRINT gnp_in_current_dollars
  679.  
  680. !    
  681. !    And notice that it, too, is now back in the workspace.
  682. !    
  683.  
  684. SYMBOLS
  685.  
  686. !    
  687. !    If you want to delete items from an attached databank, use the DISCARD
  688. !    command.  For example, suppose we want to store "pop_difference" and
  689. !    "female_proportion" in the "popdata.sdb" databank.  Let's first copy 
  690. !    the values for "pop_difference" and "female_proportion" into the 
  691. !    workspace for future use.
  692. !    
  693.  
  694. COPY pop_difference female_proportion
  695.  
  696. !    
  697. !    Then DISCARD the unwanted items.
  698. !    
  699.  
  700. DISCARD pop_difference female_proportion
  701.  
  702. !    
  703. !    To check, type CONTENTS, and Voila!
  704. !    
  705.  
  706. CONTENTS
  707.  
  708. !    
  709. !    We'll access "popdata.sdb" now to complete the transfer of information.
  710. !    
  711.  
  712. ACCESS 'a:popdata'
  713.  
  714. !    
  715. !    Note that "ecdata.sdb" will be automatically RETURNed with this command.
  716. !    
  717. !    Now KEEP the two population variables.
  718. !    
  719.  
  720. KEEP pop_difference female_proportion
  721.  
  722. !    
  723. !    But wait, there are only data for 1982 and 1983.  
  724. !    
  725.  
  726. PRINT pop_difference female_proportion
  727.  
  728. !
  729. !    We should re-generate the 1978 to 1981 values with the equations 
  730. !    we stored earlier.  Let's check to see what we have stored 
  731. !    in the databank.
  732. !    
  733.  
  734. CONTENTS
  735.  
  736. !    
  737. !    We'll retrieve the two equations and the GROUP definition, but will
  738. !    let Sampler implicitly copy the data series when they are referenced
  739. !    in equation computations.
  740. !    
  741.  
  742. COPY pop_dif fem_prop pop_group
  743.  
  744. !    
  745. !    Equations and group definitions are printible, so let's take a look.
  746. !    
  747.  
  748. PRINT pop_dif fem_prop pop_group
  749.   
  750. !    
  751. !    Check the USE period to make sure we are computing over the appropriate
  752. !    period.  Note that SORITEC Sampler makes no assumptions about the USE
  753. !    period when it copies an item from a databank.  For data series and any
  754. !    other multiple element data type that is stored, Sampler copies all
  755. !    observations regardless of active USE period.  If no USE period is
  756. !    defined, it will still copy all observations, but you will not be able
  757. !    to do anything with the data, such as PRINT it, etc. until a valid
  758. !    USE period is defined.
  759. !    
  760.  
  761. USE
  762.  
  763. !    
  764. !    We'll change the period to 1978 to 1981 and REVISE the two series so
  765. !    they incorporate all four observations.
  766. !    
  767.  
  768. USE 1978 1981
  769.  
  770. ON REVISE
  771.  
  772. !    
  773. !    Equations and identities are calculated with the COMPUTE command.
  774. !    
  775.  
  776. COMPUTE pop_dif
  777. COMPUTE fem_prop
  778.  
  779. !    
  780. !    Disable the data revision option.
  781. !    
  782.  
  783. OFF REVISE
  784.  
  785. !    
  786. !    Print out the values for 1978 to 1983.
  787. !    
  788.  
  789. USE 1978 1983
  790. PRINT pop_difference female_proportion
  791.  
  792. !    
  793. !    Now save the items in the databank.  Note, however, if you try to
  794. !    KEEP a data item that currently exists in the databank, you get
  795. !    an error message and the new data are not saved.
  796. !    
  797.  
  798. KEEP pop_difference female_proportion
  799.  
  800. !    
  801. !    Instead, you must REPLACE the data item, either with the REPLACE
  802. !    command, e.g.
  803. !    
  804.  
  805. REPLACE pop_difference
  806.  
  807. !    
  808. !    or KEEP the item with the ON REPLACE option enabled.
  809. !    
  810.  
  811. ON REPLACE
  812. KEEP female_proportion
  813. OFF REPLACE
  814.  
  815. !    
  816. !    Everything should now be set in our databank.
  817. !    
  818.  
  819. CONTENTS
  820.  
  821. !    
  822. !    To make sure that the two revised variables were replaced correctly,
  823. !    first clear the workspace and then print the items.
  824. !   
  825.  
  826. FORGET pop_difference female_proportion
  827. SYMBOLS
  828.  
  829. PRINT pop_difference female_proportion
  830.  
  831. !    
  832. !    The only thing left to show is how to delete your databanks from
  833. !    within SORITEC Sampler.  This is done with the PURGE command.  After
  834. !    the two databanks we created are purged, this demonstration is over.
  835. !    
  836.  
  837. PURGE 'a:popdata'
  838. PURGE 'a:ecdata'
  839. cls
  840. QUIT
  841.